package com.pgeg.gen;

import com.pgeg.listener.BlockListener;
import net.minecraft.block.Block;
import net.minecraft.world.gen.YOffset;
import net.minecraft.world.gen.decorator.RangeDecoratorConfig;
import net.minecraft.world.gen.feature.ConfiguredFeature;
import net.minecraft.world.gen.feature.Feature;
import net.minecraft.world.gen.feature.OreFeatureConfig;
import net.minecraft.world.gen.heightprovider.UniformHeightProvider;

public class ModOreFeature {

    public static ConfiguredFeature<?, ?> ORE_COPPER_OVERWORLD = initOreFeature(BlockListener.COPPER_ORE, 9, 0, 56, 7);
    public static ConfiguredFeature<?, ?> ORE_SILVER_OVERWORLD = initOreFeature(BlockListener.SILVER_ORE, 9, 0, 24, 4);
    public static ConfiguredFeature<?, ?> MANA_CRYSTAL_OVERWORLD = initOreFeature(BlockListener.MANA_CRYSTAL_ORE, 10, 0, 56, 5);
    public static ConfiguredFeature<?, ?> ORICHALCUM_OVERWORLD = initOreFeature(BlockListener.ORICHALCUM_ORE, 8, 0, 54, 6);
    public static ConfiguredFeature<?, ?> SATURNIUM_OVERWORLD = initOreFeature(BlockListener.SATURNIUM_ORE, 8, 0, 54, 6);
    public static ConfiguredFeature<?, ?> BRIMSTONE_OVERWORLD = initOreFeature(BlockListener.BRIMSTONE_ORE, 8, 0, 54, 6);
    public static ConfiguredFeature<?, ?> METEORITE_OVERWORLD = initOreFeature(BlockListener.METEORITE_ORE, 8, 0, 54, 6);
    public static ConfiguredFeature<?, ?> MITHRIL_OVERWORLD = initOreFeature(BlockListener.METEORITE_ORE, 8, 0, 54, 5);
    public static ConfiguredFeature<?, ?> AIR_INFUSED_STONE_OVERWORLD = initOreFeature(BlockListener.AIR_INFUSED_STONE, 6, 0, 56, 6);
    public static ConfiguredFeature<?, ?> FIRE_INFUSED_STONE_OVERWORLD = initOreFeature(BlockListener.FIRE_INFUSED_STONE, 6, 0, 56, 6);
    public static ConfiguredFeature<?, ?> EARTH_INFUSED_STONE_OVERWORLD = initOreFeature(BlockListener.EARTH_INFUSED_STONE, 6, 0, 56, 6);
    public static ConfiguredFeature<?, ?> WATER_INFUSED_STONE_OVERWORLD = initOreFeature(BlockListener.WATER_INFUSED_STONE, 6, 0, 56, 6);
    public static ConfiguredFeature<?, ?> ORDER_INFUSED_STONE_OVERWORLD = initOreFeature(BlockListener.ORDER_INFUSED_STONE, 6, 0, 56, 6);
    public static ConfiguredFeature<?, ?> ENTROPY_INFUSED_STONE = initOreFeature(BlockListener.ENTROPY_INFUSED_STONE, 6, 0, 56, 6);

    private static ConfiguredFeature<?, ?> initOreFeature(Block block, int size, int above, int fixed, int repeat) {
        return Feature.ORE
                .configure(new OreFeatureConfig(
                        OreFeatureConfig.Rules.BASE_STONE_OVERWORLD,
                        block.getDefaultState(),
                        size))
                .range(new RangeDecoratorConfig(
                        UniformHeightProvider.create(YOffset.aboveBottom(above), YOffset.fixed(fixed))))
                .spreadHorizontally()
                .repeat(repeat);
    }
}
